package com.yixun.controller;

import com.yixun.entity.YxSysMenu;
import com.yixun.mapper.MenusMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import javax.annotation.Resource;

/**
 * @author lbx create by 2021/6/1 10:29
 * @apiNote ViewController
 */
@Controller
public class ViewController {
    @Resource
    private MenusMapper menusMapper;
    
    @GetMapping("/goAddUser")
    public String goAddUser() {
        return "/sys/addUser";
    }
    
    @GetMapping("/goUserList")
    public String goUserList() {
        return "/sys/userList";
    }
    
    @GetMapping("/")
    public String goIndex( Model model) {
        model.addAttribute("menus", menusMapper.getMenus());
        return "/index";
    }
    @GetMapping("/system/menuSet/{id}")
    public String menuSet(@PathVariable Integer id,Model model) {
        YxSysMenu menuById = menusMapper.getMenuById(id);
        System.out.println(menuById);
        model.addAttribute("menus", menuById);
        return "/sys/menuSetPage";
    }
    @GetMapping("/system/{view}")
    public String goSysView(@PathVariable String view,Model model) {
            model.addAttribute("menus", menusMapper.getMenus());
        return "/sys/" + view;
    }
   
}
